<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
	<style>
		#InfoHit{color:#00F;font-weight:bold;}
		label{	color:#00F; line-height:21px; font-weight:bold; height:21px; vertical-align:middle;font-size:12px;}
		.AppName{ cursor:pointer}
	</style>
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
    <form enctype="multipart/form-data"  method="post" id="frm">
    <input type="hidden" name="Keywords" id="Keywords" value="{$Keywords}" />
    <input type="hidden" name="NowPage" id="NowPage" value="{$NowPage}" />
    <div class="table">
        <div class="toolbars">
            <li class="toolbar"><a id="btnSaveAll" href="{$Url}AddResearch"  title="添加调查项目" target="_self">添加调查项目</a></li>
            <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
            <li class="toolbar"><a id="del" onclick="BatchDel()" title="批量删除">删除</a></li>
            <li class="toolbar toolbarform">
                <label>调查主题</label><input type="text" class='textinput' name="Keywords" style="width:150px" value="{$Keywords}" id="Keywords"/>
                <input id="btnSeek" class="btnToolbarForm" type="submit" value="查询" onclick="Search()">
            </li>
        </div>
        <table class="datatable" id="datatable">
            <tr>
                <th width="35px"  nowrap="nowrap">选中</th>
                <th width="45px" nowrap="nowrap">ID</th>
                <th>调查主题</th>
                <th width="100px">触发关键词</th>
                <th width="80px" >总投票人数</th>
                <th width="200px" >起止时间</th>
                <th width="40px" >属性</th>
                <th  width="390px">操作</th>
            </tr>  
            <notempty name="App">                
                <volist name="App" id="i" key="j">
                    <tr>
                        <td><input class="checkrow" type="checkbox" name="AppID[]" value="{$i.AppID}" /></td>
                        <td>{$i.AppID}</td>
                        <td style="text-align:left">
                        <b class="AppName" rel="a{$j}">{$i.AppName}</b><br />
                        <b>链接地址：</b>{$i.AppID|WxResearchUrl}
                        </td>
                        <td><b style="color:green">{$i.AppKeyword}</b></td>
                        <td><b style="color:#0000FF" id="n{$i.AppID}">{$i.PeopleNumber}</b></td>
                        <td><b>开始时间：</b>{$i.StartTime}<br /><b>结束时间：</b>{$i.EndTime}</td>
                        <td>
                             <eq name="i.IsEnable" value="1">
                                <span style="color:#000;cursor:pointer;"  onclick="toggleStatus(this,{$i.AppID},'wx_app')">启用</span>
                            <else/>
                                <span style="color:#F00;cursor:pointer;"  onclick="toggleStatus(this,{$i.AppID},'wx_app')">禁用</span>
                            </eq>
                        </td>
                        <td class="operator">
                            <a id="btnSaveAll"  style="float:left" onclick="question({$i.AppID})"  title="设置调查题目" target="_self">设置调查题目</a>
                            <div class="btn-sep"></div>
                            <gt name="i.PeopleNumber" value="0">
                                <a id="btnCache"  style="float:left" onclick="ClearResearch({$i.AppID})"  title="清空调查数据" target="_self">清空调查数据</a>
                            </gt>
                            <div class="btn-sep"></div>
                            <a style="float:left" onclick="Edit({$i.AppID})" id="btnEdit">修改</a>
                            <div class="btn-sep"></div>
                            <a style="float:left" onclick="Del({$i.AppID})" class="btnDel">删除</a>
                        </td>
                    </tr>
                </volist>
            <else/>
                <tr><td colspan="8" id="NoData">{$Think.lang.NoDataTip}</td></tr>
            </notempty>                                
        </table>
        <div class="tfoot">
          <div class="page"><span class="pagesize">每页<span class="pz">{$AdminPageSize}</span>条</span>{$Page}</div>
        </div>
    </div>
</form>
</div>
</body>
</html>
<script type="text/javascript">
//排序
function BatchSort(){
	$.confirm("{$Think.lang.SortTip}", function () {
		$('#frm').attr("action", "__URL__/batchSortResearch");
		$('#frm').submit();
	}, function () {
		return true;
	}); 
}	

//查询
function Search(){
	$('#frm').attr("action", "__URL__/research");
	$('#frm').submit();
	return true;
}	

function Edit(id){
	url = "{$Url}modifyResearch/AppID/"+id;
	location.href = url;
}

function Del(id){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		url = "{$Url}delResearch/AppID/"+id+"/p/{$NowPage}/Keywords/{$Keywords}";
		location.href = url;
	}, function () {
		return true;
	});
}

function question(id){
	url = "{$Url}question/AppID/"+id;
	location.href = url;
	return true;
}

function BatchDel(){
	//var arrChk = $("input[name='InfoID[]'][checked]"); //在高速浏览器长度总是返回0
	var arrChk = $("input[name='AppID[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("{$Think.lang.CheckDeleteTip}");
		return;
	}
	
	$.confirm("{$Think.lang.DeleteTip}", function () {
		$('#frm').attr("action", "__URL__/batchDelResearch");
		$('#frm').submit();
	}, function () {
		return true;
	});
}

function ClearResearch(id){
	$.confirm("<div id='icon_common'>确定清空用户调查数据吗?</div>", function () {
		url = "{$Url}clearResearch/AppID/"+id;
		$.get(url, null, function(data, textStatus){
				if (data.status == 1){
					$("#n"+id).text("0"); //人数重置
					SucceedBox(data.info);
				}else if(data.status == 0){
					ErrorBox(data.info);
				}
		}, "json");
	}, function () {
		return true;
	});
}

//提示信息
$(document).ready(function(){
	$(".AppName").powerFloat({
		reverseSharp:true,
		position:"4-5"
	});
	
	//选中操作
	$("#Keywords").focus();
});
</script>